<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>eureka、zookeeper、consul与CAP理论 | rongshen</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/highlight.css">

  
  <meta name="description" content="比较eureka、zookeeper、consul三种微服务注册中心。笔记整理自尚硅谷周阳老师。">
<meta property="og:type" content="article">
<meta property="og:title" content="eureka、zookeeper、consul与CAP理论">
<meta property="og:url" content="http://example.com/2020/09/25/eureka%E3%80%81zookeeper%E3%80%81consul%E4%B8%8ECAP%E7%90%86%E8%AE%BA/index.html">
<meta property="og:site_name" content="rongshen">
<meta property="og:description" content="比较eureka、zookeeper、consul三种微服务注册中心。笔记整理自尚硅谷周阳老师。">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://cdn.rongshen2020.com/2020925b1.png">
<meta property="og:image" content="http://cdn.rongshen2020.com/2020925b2.png">
<meta property="og:image" content="http://cdn.rongshen2020.com/2020925b3.png">
<meta property="article:published_time" content="2020-09-25T14:55:16.000Z">
<meta property="article:modified_time" content="2021-05-07T06:43:34.069Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="springCloud">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://cdn.rongshen2020.com/2020925b1.png"><meta name="generator" content="Hexo 6.1.0"></head>

<body>
  <div id="wrapper">
    <header id="header">
  <h1 id="title">
    <a href="/">rongshen</a>
  </h1>
  <nav>
    
    
      
      <a class="nav-link" href="/">Home</a>
    
      
        <span class="nav-spacer">×</span>
      
      <a class="nav-link" href="/archives">Archives</a>
    
      
        <span class="nav-spacer">×</span>
      
      <a class="nav-link" target="_blank" rel="noopener" href="https://github.com/Aaron-boom">Github</a>
    
      
        <span class="nav-spacer">×</span>
      
      <a class="nav-link" href="/2020/04/13/About-Me/">About</a>
    
    
  </nav>
</header>

    <div id="content">
      <article id="post-eureka、zookeeper、consul与CAP理论" class="article article-type-post" itemprop="blogPost" itemscope>
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h2 class="article-title" itemprop="headline name">
      eureka、zookeeper、consul与CAP理论
    </h2>
  


        <div class="article-meta">
          <time class="article-date" datetime="2020-09-25T14:55:16.000Z" itemprop="datePublished">2020-09-25</time>

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
      
        <blockquote>
<p>比较eureka、zookeeper、consul三种微服务注册中心。笔记整理自尚硅谷周阳老师。</p>
</blockquote>
<span id="more"></span>


<h2 id="CAP理论："><a href="#CAP理论：" class="headerlink" title="CAP理论："></a>CAP理论：</h2><p>CAP原则又称CAP定理，指的是在一个<a target="_blank" rel="noopener" href="https://baike.baidu.com/item/%E5%88%86%E5%B8%83%E5%BC%8F%E7%B3%BB%E7%BB%9F/4905336">分布式系统</a>中， Consistency（一致性）、 Availability（可用性）、Partition tolerance（分区容错性），三者不可得兼。</p>
<p>一致性（C）：在<a target="_blank" rel="noopener" href="https://baike.baidu.com/item/%E5%88%86%E5%B8%83%E5%BC%8F%E7%B3%BB%E7%BB%9F/4905336">分布式系统</a>中的所有数据备份，在同一时刻是否同样的值。（等同于所有节点访问同一份最新的数据副本）</p>
<p>可用性（A）：在集群中一部分节点故障后，<a target="_blank" rel="noopener" href="https://baike.baidu.com/item/%E9%9B%86%E7%BE%A4/5486962">集群</a>整体是否还能响应<a target="_blank" rel="noopener" href="https://baike.baidu.com/item/%E5%AE%A2%E6%88%B7%E7%AB%AF/101081">客户端</a>的读写请求。（对数据更新具备高可用性）</p>
<p>分区容忍性（P）：以实际效果而言，分区相当于对通信的时限要求。系统如果不能在时限内达成数据一致性，就意味着发生了分区的情况，必须就当前操作在C和A之间做出选择。</p>
<p>CAP原则的精髓就是要么AP，要么CP，要么AC，但是不存在CAP。</p>
<h2 id="三个注册中心的异同："><a href="#三个注册中心的异同：" class="headerlink" title="三个注册中心的异同："></a>三个注册中心的异同：</h2><p><img src="http://cdn.rongshen2020.com/2020925b1.png"></p>
<h2 id="总结："><a href="#总结：" class="headerlink" title="总结："></a>总结：</h2><p>CAP理论的核心是：一个分布式系统不可能同时很好的满足一致性、可用性和分区容错性这三个需求。因此，根据CAP原理将NoSQL数据库分成了满足CA原则、满足CP原则和满足AP原则三大类：</p>
<ul>
<li>CA：单点集群，满足一致性，可用性的系统，通常在可扩展性上不太强大。</li>
<li>CP：满足一致性，分区容忍性的系统，通常性能不是特别高。</li>
<li>AP：满足可用性，分区容忍性的系统，通常可能对一致性要求低一点。</li>
</ul>
<p><img src="http://cdn.rongshen2020.com/2020925b2.png"></p>
<p><img src="http://cdn.rongshen2020.com/2020925b3.png"></p>

      
    </div>
    
    
    <div class="article-category">
      
        <b>Categories:</b>
        <a class="article-category-link" href="/categories/spring-cloud/">spring cloud</a>
      
      
        <br/>
      
      
        <b>Tags:</b>
        <a class="article-tag-none-link" href="/tags/springCloud/" rel="tag">springCloud</a>
      
    </div>
    
    
  </div>
</article>

  
<nav id="article-nav" class="article-nav">
  
    <a href="/2020/09/26/%E5%9C%A8IDEA%E4%B8%AD%E5%BC%80%E5%90%AF%E7%83%AD%E9%83%A8%E7%BD%B2%E4%B8%8ERun-Dashboard/" id="article-nav-newer" class="article-nav-link-wrap newer">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          在IDEA中开启热部署与Run Dashboard
        
      </div>
    </a>
  
  
    <a href="/2020/09/25/springcloud%E4%B9%8Bconsul/" id="article-nav-older" class="article-nav-link-wrap older">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">
        
          springcloud之consul
        
      </div>
    </a>
  
</nav>






    </div>
  </div>
  




<div id="settings-container">
  <div id="dark-mode">dark</div>
  <div id="sans-font">sans</div>
</div>
<script type="text/javascript">
let d=document,r=d.documentElement.style,f=r.setProperty.bind(r),l=localStorage,s=l.getItem('s')||(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches),n=l.getItem('n'),m=d.getElementById("dark-mode"),b=()=>{f('--bg-color','#fafafa');f('--code-bg-color','#f4f4f4');f('--text-color','#212121');f('--secondary-color','#808080');f('--tertiary-color','#b0b0b0');f('--link-color','#b5c8cf');f('--link-hover-color','#618794');f('--link-bg-color','#dae4e7');f('--selection-color','#dae4e7');m.innerHTML="dark"},c=()=>{f('--bg-color','#212121');f('--code-bg-color','#292929');f('--text-color','#fff');f('--secondary-color','#c0c0c0');f('--tertiary-color','#6e6e6e');f('--link-color','#4d6b75');f('--link-hover-color','#96b1bb');f('--link-bg-color','#5d828e');f('--selection-color','#acc1c9');m.innerHTML="light"},o=d.getElementById("sans-font"),e=()=>{f('--body-stack','"Lora", "Georgia", "Times New Roman", serif');o.innerHTML="sans"},g=()=>{f('--body-stack','"Lato", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "Verdana", sans-serif');o.innerHTML="serif"};m.onclick=()=>{if(s==2){s=1;l.setItem('s',s);c()}else{s=2;l.setItem('s',s);b()}};o.onclick=()=>{if(n==2){n=1;l.setItem('n',n);g()}else{n=2;l.setItem('n',n);e()}};if(!s){s=2;l.setItem('s',2)};if(s==1){c()};if(!n){n=2;l.setItem('n',2)};if(n==1){g()};
</script>




</body>
</html>
